$(function() {
    $("#myPage").click(function() {
        overdue(),
            window.location.href = "skipMyPage"
    });
    var s = result.noticeList;
    inNoticeList(s);
    var a = new Loading;
    a.init();
    var e = new Alert,
        t = new Confirm,
        l = result.totalPage,
        r = result.pageNow,
        o = result.pageSize;
    if (void 0 != result.classList) for (c = 0; c < result.classList.length; c++) n = '<option value="' + result.classList[c].classId + '">' + result.classList[c].className + "</option>",
        $("#classSel").append(n);
    if (void 0 != result.classId && null != result.classId && 0 != result.classId && $("#classSel").val(result.classId), void 0 != result.classEndMark && null != result.classEndMark && $("#state").val(result.classEndMark), void 0 != result.classCourseList && 0 != result.classCourseList.length) for (var c = 0; c < result.classCourseList.length; c++) {
        var n = "";
        n = c % 2 == 0 ? '<tr class="">': '<tr class="gray-tr-new">';
        var i = "",
            d = "";
        0 == result.classCourseList[c].classEndMark ? (i = "教学中", d = '<a href="javascript:void(0);" class="operate font-color endButton" courseId="' + result.classCourseList[c].courseId + '" classId="' + result.classCourseList[c].classId + '">结课</a><a href="javascript:void(0);" class="operate font-color lookforVirtual" courseId="' + result.classCourseList[c].courseId + '" classId="' + result.classCourseList[c].classId + '">查看虚拟机</a><a class="font-color phone" href="javascript:void(0);" courseId="' + result.classCourseList[c].courseId + '" classId="' + result.classCourseList[c].classId + '" style="padding-left: 5px">手机考勤</a>') : i = "已结束",
            n = n + '<td class="head1">' + ((r - 1) * o + c + 1) + '</td><td class="head1" title="' + result.classCourseList[c].className + '">' + result.classCourseList[c].className + ' </td><td class="head1" title="' + result.classCourseList[c].courseName + '">' + result.classCourseList[c].courseName + '</td><td class="head1">' + i + '</td><td class="head1" >' + d + "</td></tr>",
            $("#classList").append(n)
    }
    $(".operate").hover(function() {

            var s = $(this);
            s.removeClass("font-color"),
                s.addClass("font-color-red")
        },
        function() {
            $(this).removeClass("font-color-red"),
                $(this).addClass("font-color")
        }),
        $(".lookforVirtual").click(function() {
            var s = $(this).attr("classId");
            window.location.href = 'skipVirtualMachineClass?jsonStr={"pageNow":1,"pageSize":8,"classId":' + s + "}"
        }),
        $(".endButton").click(function() {
            overdue();
            var s = $(this);
            t.content = "您所选择的课程未结束，需要提前结束吗？",
                t.init(),
                addchangeColor(),
                t.success = function() {
                    var t = '{"classId":' + s.attr("classId") + ',"courseId":' + s.attr("courseId") + "}";
                    a.show(),
                        $.ajax({
                            type: "post",
                            url: "endCourseClass",
                            data: {
                                jsonStr: t
                            },
                            success: function(s) {
                                a.hide(),
                                    "success" == (s = JSON.parse(s)).result ? (e.content = "结课成功", e.success = function() {
                                        window.location.href = 'skipTeaEndClassList?jsonStr={"pageNow":1,"pageSize":10}'
                                    },
                                        e.init(), addchangeColor(), e.show()) : (e.content = "结课失败", e.init(), addchangeColor(), e.show())
                            },
                            error: function() {
                                e.content = "结课失败",
                                    e.init(),
                                    addchangeColor(),
                                    e.show()
                            }
                        })
                },
                t.show()
        }),
        $(".phone").click(function() {

            var json = JSON.stringify({
                "pageName": "pc/phone",
                "paramData": {
                    "classId": $(this).attr("classId"),
                    "courseId": $(this).attr("courseId")
                }
            });
           window.location.href = "skipPage?jsonStr="+json
        }),
        $("#searchBtn").click(function() {
            overdue();
            var s = '{"pageNow":1,"pageSize":10,"classId":' + $("#classSel").val() + ',"classEndMark":' + $("#state").val() + "}";
            window.location.href = "skipTeaEndClassList?jsonStr=" + s
        }),
        $(".tcdPageCode").createPage({
            pageCount: l,
            current: r,
            pageNumber: o,
            backFn: function(s) { (r = s) >= l && (r = l);
                var a = '{"pageNow":' + r + ',"pageSize":10,"classId":' + result.classId + ',"classEndMark":' + result.classEndMark + "}";
                overdue(),
                    window.location.href = "skipTeaEndClassList?jsonStr=" + a
            }
        })
});